package o;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.Callback;
import android.graphics.drawable.Drawable.ConstantState;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class ot extends ou implements oq {
    private Context ˊ;
    final Callback ˋ;
    ArrayList<o.oq.d> ˏ;
    private d ॱ;
    private ArgbEvaluator ॱॱ;
    private AnimatorListener ᐝ;

    static class d extends ConstantState {
        int ˊ;
        AnimatorSet ˋ;
        ArrayList<Animator> ˎ;
        ov ˏ;
        ds<Animator, String> ॱ;

        public d(Context context, d dVar, Callback callback, Resources resources) {
            int i = 0;
            if (dVar != null) {
                this.ˊ = dVar.ˊ;
                if (dVar.ˏ != null) {
                    ConstantState constantState = dVar.ˏ.getConstantState();
                    if (resources != null) {
                        this.ˏ = (ov) constantState.newDrawable(resources);
                    } else {
                        this.ˏ = (ov) constantState.newDrawable();
                    }
                    this.ˏ = (ov) this.ˏ.mutate();
                    this.ˏ.setCallback(callback);
                    this.ˏ.setBounds(dVar.ˏ.getBounds());
                    this.ˏ.ॱ(false);
                }
                if (dVar.ˎ != null) {
                    int size = dVar.ˎ.size();
                    this.ˎ = new ArrayList(size);
                    this.ॱ = new ds(size);
                    while (i < size) {
                        Animator animator = (Animator) dVar.ˎ.get(i);
                        Animator clone = animator.clone();
                        String str = (String) dVar.ॱ.get(animator);
                        clone.setTarget(this.ˏ.ˏ(str));
                        this.ˎ.add(clone);
                        this.ॱ.put(clone, str);
                        i++;
                    }
                    ॱ();
                }
            }
        }

        public Drawable newDrawable() {
            throw new IllegalStateException("No constant state support for SDK < 24.");
        }

        public Drawable newDrawable(Resources resources) {
            throw new IllegalStateException("No constant state support for SDK < 24.");
        }

        public int getChangingConfigurations() {
            return this.ˊ;
        }

        public void ॱ() {
            if (this.ˋ == null) {
                this.ˋ = new AnimatorSet();
            }
            this.ˋ.playTogether(this.ˎ);
        }
    }

    @RequiresApi(24)
    static class e extends ConstantState {
        private final ConstantState ˋ;

        public e(ConstantState constantState) {
            this.ˋ = constantState;
        }

        public Drawable newDrawable() {
            Drawable otVar = new ot();
            otVar.ˎ = this.ˋ.newDrawable();
            otVar.ˎ.setCallback(otVar.ˋ);
            return otVar;
        }

        public Drawable newDrawable(Resources resources) {
            Drawable otVar = new ot();
            otVar.ˎ = this.ˋ.newDrawable(resources);
            otVar.ˎ.setCallback(otVar.ˋ);
            return otVar;
        }

        public Drawable newDrawable(Resources resources, Theme theme) {
            Drawable otVar = new ot();
            otVar.ˎ = this.ˋ.newDrawable(resources, theme);
            otVar.ˎ.setCallback(otVar.ˋ);
            return otVar;
        }

        public boolean canApplyTheme() {
            return this.ˋ.canApplyTheme();
        }

        public int getChangingConfigurations() {
            return this.ˋ.getChangingConfigurations();
        }
    }

    public /* bridge */ /* synthetic */ void clearColorFilter() {
        super.clearColorFilter();
    }

    public /* bridge */ /* synthetic */ ColorFilter getColorFilter() {
        return super.getColorFilter();
    }

    public /* bridge */ /* synthetic */ Drawable getCurrent() {
        return super.getCurrent();
    }

    public /* bridge */ /* synthetic */ int getMinimumHeight() {
        return super.getMinimumHeight();
    }

    public /* bridge */ /* synthetic */ int getMinimumWidth() {
        return super.getMinimumWidth();
    }

    public /* bridge */ /* synthetic */ boolean getPadding(Rect rect) {
        return super.getPadding(rect);
    }

    public /* bridge */ /* synthetic */ int[] getState() {
        return super.getState();
    }

    public /* bridge */ /* synthetic */ Region getTransparentRegion() {
        return super.getTransparentRegion();
    }

    public /* bridge */ /* synthetic */ void jumpToCurrentState() {
        super.jumpToCurrentState();
    }

    public /* bridge */ /* synthetic */ void setChangingConfigurations(int i) {
        super.setChangingConfigurations(i);
    }

    public /* bridge */ /* synthetic */ void setColorFilter(int i, Mode mode) {
        super.setColorFilter(i, mode);
    }

    public /* bridge */ /* synthetic */ void setFilterBitmap(boolean z) {
        super.setFilterBitmap(z);
    }

    public /* bridge */ /* synthetic */ void setHotspot(float f, float f2) {
        super.setHotspot(f, f2);
    }

    public /* bridge */ /* synthetic */ void setHotspotBounds(int i, int i2, int i3, int i4) {
        super.setHotspotBounds(i, i2, i3, i4);
    }

    public /* bridge */ /* synthetic */ boolean setState(int[] iArr) {
        return super.setState(iArr);
    }

    ot() {
        this(null, null, null);
    }

    private ot(@Nullable Context context) {
        this(context, null, null);
    }

    private ot(@Nullable Context context, @Nullable d dVar, @Nullable Resources resources) {
        this.ॱॱ = null;
        this.ᐝ = null;
        this.ˏ = null;
        this.ˋ = new Callback(this) {
            final /* synthetic */ ot ˎ;

            {
                this.ˎ = r1;
            }

            public void invalidateDrawable(Drawable drawable) {
                this.ˎ.invalidateSelf();
            }

            public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
                this.ˎ.scheduleSelf(runnable, j);
            }

            public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
                this.ˎ.unscheduleSelf(runnable);
            }
        };
        this.ˊ = context;
        if (dVar != null) {
            this.ॱ = dVar;
        } else {
            this.ॱ = new d(context, dVar, this.ˋ, resources);
        }
    }

    public Drawable mutate() {
        if (this.ˎ != null) {
            this.ˎ.mutate();
        }
        return this;
    }

    public static ot ˊ(Context context, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Theme theme) throws XmlPullParserException, IOException {
        ot otVar = new ot(context);
        otVar.inflate(resources, xmlPullParser, attributeSet, theme);
        return otVar;
    }

    public ConstantState getConstantState() {
        if (this.ˎ == null || VERSION.SDK_INT < 24) {
            return null;
        }
        return new e(this.ˎ.getConstantState());
    }

    public int getChangingConfigurations() {
        if (this.ˎ != null) {
            return this.ˎ.getChangingConfigurations();
        }
        return super.getChangingConfigurations() | this.ॱ.ˊ;
    }

    public void draw(Canvas canvas) {
        if (this.ˎ != null) {
            this.ˎ.draw(canvas);
            return;
        }
        this.ॱ.ˏ.draw(canvas);
        if (this.ॱ.ˋ.isStarted()) {
            invalidateSelf();
        }
    }

    protected void onBoundsChange(Rect rect) {
        if (this.ˎ != null) {
            this.ˎ.setBounds(rect);
        } else {
            this.ॱ.ˏ.setBounds(rect);
        }
    }

    protected boolean onStateChange(int[] iArr) {
        if (this.ˎ != null) {
            return this.ˎ.setState(iArr);
        }
        return this.ॱ.ˏ.setState(iArr);
    }

    protected boolean onLevelChange(int i) {
        if (this.ˎ != null) {
            return this.ˎ.setLevel(i);
        }
        return this.ॱ.ˏ.setLevel(i);
    }

    public int getAlpha() {
        if (this.ˎ != null) {
            return gg.ˏ(this.ˎ);
        }
        return this.ॱ.ˏ.getAlpha();
    }

    public void setAlpha(int i) {
        if (this.ˎ != null) {
            this.ˎ.setAlpha(i);
        } else {
            this.ॱ.ˏ.setAlpha(i);
        }
    }

    public void setColorFilter(ColorFilter colorFilter) {
        if (this.ˎ != null) {
            this.ˎ.setColorFilter(colorFilter);
        } else {
            this.ॱ.ˏ.setColorFilter(colorFilter);
        }
    }

    public void setTint(int i) {
        if (this.ˎ != null) {
            gg.ॱ(this.ˎ, i);
        } else {
            this.ॱ.ˏ.setTint(i);
        }
    }

    public void setTintList(ColorStateList colorStateList) {
        if (this.ˎ != null) {
            gg.ॱ(this.ˎ, colorStateList);
        } else {
            this.ॱ.ˏ.setTintList(colorStateList);
        }
    }

    public void setTintMode(Mode mode) {
        if (this.ˎ != null) {
            gg.ˋ(this.ˎ, mode);
        } else {
            this.ॱ.ˏ.setTintMode(mode);
        }
    }

    public boolean setVisible(boolean z, boolean z2) {
        if (this.ˎ != null) {
            return this.ˎ.setVisible(z, z2);
        }
        this.ॱ.ˏ.setVisible(z, z2);
        return super.setVisible(z, z2);
    }

    public boolean isStateful() {
        if (this.ˎ != null) {
            return this.ˎ.isStateful();
        }
        return this.ॱ.ˏ.isStateful();
    }

    public int getOpacity() {
        if (this.ˎ != null) {
            return this.ˎ.getOpacity();
        }
        return this.ॱ.ˏ.getOpacity();
    }

    public int getIntrinsicWidth() {
        if (this.ˎ != null) {
            return this.ˎ.getIntrinsicWidth();
        }
        return this.ॱ.ˏ.getIntrinsicWidth();
    }

    public int getIntrinsicHeight() {
        if (this.ˎ != null) {
            return this.ˎ.getIntrinsicHeight();
        }
        return this.ॱ.ˏ.getIntrinsicHeight();
    }

    public boolean isAutoMirrored() {
        if (this.ˎ != null) {
            return gg.ˊ(this.ˎ);
        }
        return this.ॱ.ˏ.isAutoMirrored();
    }

    public void setAutoMirrored(boolean z) {
        if (this.ˎ != null) {
            gg.ˏ(this.ˎ, z);
        } else {
            this.ॱ.ˏ.setAutoMirrored(z);
        }
    }

    public void inflate(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Theme theme) throws XmlPullParserException, IOException {
        if (this.ˎ != null) {
            gg.ˎ(this.ˎ, resources, xmlPullParser, attributeSet, theme);
            return;
        }
        int eventType = xmlPullParser.getEventType();
        int depth = xmlPullParser.getDepth() + 1;
        while (eventType != 1 && (xmlPullParser.getDepth() >= depth || eventType != 3)) {
            if (eventType == 2) {
                String name = xmlPullParser.getName();
                TypedArray ˎ;
                if ("animated-vector".equals(name)) {
                    ˎ = fx.ˎ(resources, theme, attributeSet, op.ˎ);
                    int resourceId = ˎ.getResourceId(0, 0);
                    if (resourceId != 0) {
                        ov ˋ = ov.ˋ(resources, resourceId, theme);
                        ˋ.ॱ(false);
                        ˋ.setCallback(this.ˋ);
                        if (this.ॱ.ˏ != null) {
                            this.ॱ.ˏ.setCallback(null);
                        }
                        this.ॱ.ˏ = ˋ;
                    }
                    ˎ.recycle();
                } else if ("target".equals(name)) {
                    ˎ = resources.obtainAttributes(attributeSet, op.ʻ);
                    String string = ˎ.getString(0);
                    int resourceId2 = ˎ.getResourceId(1, 0);
                    if (resourceId2 != 0) {
                        if (this.ˊ != null) {
                            ˋ(string, ow.ॱ(this.ˊ, resourceId2));
                        } else {
                            ˎ.recycle();
                            throw new IllegalStateException("Context can't be null when inflating animators");
                        }
                    }
                    ˎ.recycle();
                } else {
                    continue;
                }
            }
            eventType = xmlPullParser.next();
        }
        this.ॱ.ॱ();
    }

    public void inflate(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet) throws XmlPullParserException, IOException {
        inflate(resources, xmlPullParser, attributeSet, null);
    }

    public void applyTheme(Theme theme) {
        if (this.ˎ != null) {
            gg.ˎ(this.ˎ, theme);
        }
    }

    public boolean canApplyTheme() {
        if (this.ˎ != null) {
            return gg.ˋ(this.ˎ);
        }
        return false;
    }

    private void ˋ(Animator animator) {
        if (animator instanceof AnimatorSet) {
            List childAnimations = ((AnimatorSet) animator).getChildAnimations();
            if (childAnimations != null) {
                for (int i = 0; i < childAnimations.size(); i++) {
                    ˋ((Animator) childAnimations.get(i));
                }
            }
        }
        if (animator instanceof ObjectAnimator) {
            ObjectAnimator objectAnimator = (ObjectAnimator) animator;
            String propertyName = objectAnimator.getPropertyName();
            if ("fillColor".equals(propertyName) || "strokeColor".equals(propertyName)) {
                if (this.ॱॱ == null) {
                    this.ॱॱ = new ArgbEvaluator();
                }
                objectAnimator.setEvaluator(this.ॱॱ);
            }
        }
    }

    private void ˋ(String str, Animator animator) {
        animator.setTarget(this.ॱ.ˏ.ˏ(str));
        if (VERSION.SDK_INT < 21) {
            ˋ(animator);
        }
        if (this.ॱ.ˎ == null) {
            this.ॱ.ˎ = new ArrayList();
            this.ॱ.ॱ = new ds();
        }
        this.ॱ.ˎ.add(animator);
        this.ॱ.ॱ.put(animator, str);
    }

    public boolean isRunning() {
        if (this.ˎ != null) {
            return ((AnimatedVectorDrawable) this.ˎ).isRunning();
        }
        return this.ॱ.ˋ.isRunning();
    }

    public void start() {
        if (this.ˎ != null) {
            ((AnimatedVectorDrawable) this.ˎ).start();
        } else if (!this.ॱ.ˋ.isStarted()) {
            this.ॱ.ˋ.start();
            invalidateSelf();
        }
    }

    public void stop() {
        if (this.ˎ != null) {
            ((AnimatedVectorDrawable) this.ˎ).stop();
        } else {
            this.ॱ.ˋ.end();
        }
    }
}
